package com.zmn.brs.common.model.mq;

import com.zmn.brs.common.enums.EventEnum;
import com.zmn.brs.common.enums.PlatEnum;
import com.zmn.common.constant.GlobalConsts;
import lombok.*;

import java.io.Serializable;
import java.util.Date;
import java.util.Objects;

/**
 * 类描述：操作记录消息
 *
 * @author zhangyao
 * @since 2021/04/20 11:27
 */
@Data
@Builder
@AllArgsConstructor
@NoArgsConstructor
@ToString
public class OperateRecordMq implements Serializable {

    /**
     * 下单入口，小类
     */
    private Integer gate;

    /**
     * 平台
     */
    private PlatEnum plat;

    /**
     * 渠道ID
     */
    private Integer channelId;

    /**
     * 事件
     */
    private EventEnum event;

    /**
     * 对象身份
     */
    private Integer objectIdentity;

    /**
     * 对象ID
     */
    private Long objectId;

    /**
     * 对象手机号
     */
    private String objectMobile;

    /**
     * 对象IP地址
     */
    private String objectIp;

    /**
     * 创建时间
     */
    private Date createTime;

    /**
     * 判断对象ID是否是：系统（值为0或1）
     * @param objectId 对象ID
     * @return boolean true:是
     * @throws
     * @author zhangyao
     * @since 2021/05/13 3:05 PM
     */
    public static boolean getObjectIdIsSystem(Long objectId) {
        return Objects.nonNull(objectId)
                && (GlobalConsts.NONE == objectId
                || GlobalConsts.NO == objectId);
    }

    /**
     * 判断对象身份是否在监控范围内：员工、工程师、用户、厂商、服务商
     * @param objectIdentity 对象身份
     * @return boolean true:是
     * @throws
     * @author zhangyao
     * @since 2021/05/13 3:05 PM
     */
    public static boolean getObjectIdentityIsMonitoringScope(Integer objectIdentity) {
        return Objects.nonNull(objectIdentity)
                && (GlobalConsts.OPERATE_USER_TYPE_STAFF == objectIdentity
                || GlobalConsts.OPERATE_USER_TYPE_MASTER == objectIdentity
                || GlobalConsts.OPERATE_USER_TYPE_USER == objectIdentity
                || GlobalConsts.OPERATE_USER_TYPE_FACTORY == objectIdentity
                || GlobalConsts.OPERATE_USER_TYPE_SERVICEPROVIDER == objectIdentity);
    }
}
